import React, {Component} from "react";
import DetailHead from '../components/DetailHead';
import Table from "../../../component/Table";
import Tabs from '../../../component/Tab';
import { formatTime } from '@/utils'
import { formatStatus } from '@/utils/format'

class Index extends Component{

    state = {
        columns: [
            {
                title: '#',
                width: 60,
                fixed: 'left',
                render: (text, record, index) => {
                    const {current,pageSize} = this.state.pagination;
                    return (current-1) * pageSize + (index+1)
                }
            },
            {
                title: '课程名称',
                ellipsis: true,
                dataIndex: 'curriculumName',
                width: 120
            },
            {
                title: '课时名称',
                dataIndex: 'classHourName',
                width: 120
            },
            {
                title: '授课课时',
                width: 100,
                render: (text) => {
                    return text.orderNum + '/' + text.classHour
                }
            },
            {
                title: '上课时间',
                ellipsis: true,
                width: 200,
                render: (text) => {
                    return text.startTime + ' ~ ' + text.endTime
                }
            },
            {
                title: '授课教师',
                dataIndex: 'teacherName',
                width: 120
            }
        ],
        pagination: {
            current: 1,
            pageSize: 15
        },
        params: {
            paramsMap: {
                classCode: this.props.match.params.cd || ''
            },
            sortName: "start_time",
            sortType: "desc"
        },
        request: {
            method: 'post',
            url: '/Classhour/getClassHourPage'
        }
    };

    state1 = {
        columns: [
            {
                title: '#',
                width: 60,
                fixed: 'left',
                render: (text, record, index) => {
                    const {current,pageSize} = this.state1.pagination;
                    return (current-1) * pageSize + (index+1)
                }
            },
            {
                title: '学生姓名',
                dataIndex: 'userName',
                width: 100
            },
            {
                title: '账号',
                dataIndex: 'account',
                width: 120
            },
            {
                title: '性别',
                dataIndex: 'sex',
                width: 80
            },
            {
                title: '联系方式',
                dataIndex: 'telephone',
                width: 120
            },
            {
                title: '添加人',
                dataIndex: 'addUser',
                width: 100
            },
            {
                title: '添加时间',
                width: 120,
                render: (text) => formatTime(text.addTime, 16)
            },
            {
                title: '账号状态',
                width: 100,
                render: (text) => formatStatus(text.accountStatus)
            }
        ],
        pagination: {
            current: 1,
            pageSize: 15
        },
        params: {
            paramsMap: {
                classCode: this.props.match.params.cd || ''
            },
            sortName: "add_time",
            sortType: "desc"
        },
        request: {
            method: 'post',
            url: '/CollegeUser/getStudentPage',
            headers: {}
        }
    };

    render() {
        return (
            <div className="table-detail">
                <DetailHead />
                <Tabs defaultActiveKey="1" onChange={this.callback}>
                    <tab-item name="排课信息" key="1">
                        <Table config={this.state}/>
                    </tab-item>
                    <tab-item name="花名册" key="2">
                        <Table config={this.state1}/>
                    </tab-item>
                </Tabs>
            </div>
        )
    }

    callback (index){
        console.log(index);
    }
}

export default Index;